package com.byt.netapi;

import com.byt.base.preference.SharePerUtils;

/**
 * 类名称：   ApiConfig
 * 创建时间： 2017/10/26.
 * 类描述：   服务器HOST地址
 */
public class ApiConfig {
    public static final String RELEASE_SERVER_DOMAIN = "https://www.xmxbaby.com/tp5/public/index.php/"; // 正式环境
    public static final String RELEASE_TEST_SERVER_DOMAIN = "https://demo.xmxbaby.com/tp5/public/index.php/";// 正式环境下的测试环境
    public static final String TEST_SERVER_DOMAIN = "http://192.168.1.254/tp5/public/index.php/"; // 测试环境
    public static final String Url_SERVER_DOMAIN = "http://www.xmxbaby.com"; // 掌馨医对一

    public static final class Host {
        //连接超时时间
        public static final int DEFAULT_TIME_OUT = 30;
        //写操作超时时间
        public static final int DEFAULT_TIME_WRITE = 30;
        //读操作超时时间
        public static final int DEFAULT_TIME_READ = 30;
    }

    public static final int boolena_RELEASE_ENVIRONMENT = isReleaseEnvironment();

    public static final String IS_RELEASE_ENVIRONMENT = "RELEASE_ENVIRONMENT_BOOLEAN";

    private static final int isReleaseEnvironment() {
        return SharePerUtils.getInstance().getInt(IS_RELEASE_ENVIRONMENT, 0);
    }

    public static final String getNewsServerDomain() {
        if (boolena_RELEASE_ENVIRONMENT == 0) {
            return RELEASE_SERVER_DOMAIN;
        } else if (boolena_RELEASE_ENVIRONMENT == 1) {
            return RELEASE_TEST_SERVER_DOMAIN;
        } else if (boolena_RELEASE_ENVIRONMENT == 2) {
            return TEST_SERVER_DOMAIN;
        } else {
            return RELEASE_SERVER_DOMAIN;
        }
    }

    public static final String getH5ServerDomain() {
        if (boolena_RELEASE_ENVIRONMENT == 0) {
            return "https://www.xmxbaby.com";
        } else if (boolena_RELEASE_ENVIRONMENT == 1) {
            return "https://demo.xmxbaby.com";
        } else if (boolena_RELEASE_ENVIRONMENT == 2) {
            return "http://192.168.1.254";
        } else {
            return "https://www.xmxbaby.com";
        }
    }
}